package org.shiro.service.impl;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.shiro.basic.entity.SystemUser;
import org.shiro.mapper.SystemUserMapper;
import org.shiro.service.SystemUserService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Optional;

/**
 * 系统用户相关操作接口实现类
 *
 * @author LiKun
 * @date 2021/11/2 22:32
 */
@Validated
@Service("systemUserService")
public class SystemUserServiceImpl implements SystemUserService, Serializable {
    @Resource
    private SystemUserMapper systemUserMapper;

    @Override
    @RequiresAuthentication
    public Optional<SystemUser> findSystemUser(@NotEmpty String username) {
        return Optional.ofNullable(systemUserMapper.selectByUsername(username));
    }
}
